﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace XML_X
{
    class Program
    {
        static void Main(string[] args)
        {
           // CreatBooksXml();

            XMLFile.Open("Books.xml", "Books");

            XmlElement node;

            node = XMLFile.AppendNewNode("Book", "Books");
            {
                node = XMLFile.AppendNewNode("Name", "Books", "Book");
                node.InnerText = "西游记";
                node.SetAttribute("s", "ss");
                node = XMLFile.AppendNewNode("Price", "Books", "Book");
                node.InnerText = "13";
                node = XMLFile.AppendNewNode("Count", "Books", "Book");
                node.InnerText = "11本";
            }
            XMLFile.Close("Books.xml");

            //CreatTeachersXml();

            //CreatStudentsXml();

            //XMLFile.Open("Students.xml", "Students");
            //XmlElement node;
            //node = XMLFile.AppendNewNode("赵同学", "Students", "Student");
            //node.SetAttribute("Name", "赵小天");
            //node.SetAttribute("数学成绩", "142");
            //node.SetAttribute("语文成绩", "114");
            //node.SetAttribute("化学成绩", "78");
            //node = XMLFile.AppendNewNode("高同学", "Students", "Student");
            //node.SetAttribute("Name", "高鹏");
            //node.SetAttribute("数学成绩", "130");
            //node.SetAttribute("语文成绩", "144");
            //node.SetAttribute("化学成绩", "68");

            //XMLFile.Close("Students.xml");


            //XMLFile.GetXmlFileAllRoute("Peoples.xml");


            
            Console.ReadKey();
        }
        
        private static void CreatStudentsXml()
        {
            
            XMLFile.Open("Students.xml", "Students");
            XmlElement node;
            node = XMLFile.AppendNewNode("Student", "Students");
            {
                node = XMLFile.AppendNewNode("张同学", "Students", "Student");
                node.SetAttribute("Name", "张兰");
                node.SetAttribute("数学成绩", "120");
                node.SetAttribute("语文成绩", "130");
                node.SetAttribute("化学成绩", "75");

                node = XMLFile.AppendNewNode("吴同学", "Students", "Student");
                node.SetAttribute("Name", "吴欧");
                node.SetAttribute("数学成绩", "112");
                node.SetAttribute("语文成绩", "115");
                node.SetAttribute("化学成绩", "80");
                
            }           
            XMLFile.Close("Students.xml");
            
        }

        private static void CreatTeachersXml()
        {
            
            XMLFile.Open("Teachers.xml","Teachers");
            XmlElement node;
            node = XMLFile.AppendNewNode("男老师", "Teachers");
            {
                node = XMLFile.AppendNewNode("王老师", "Teachers", "男老师");
                node.SetAttribute("Name", "王强");
                node.SetAttribute("Subject", "数学");
                node.SetAttribute("Age", "25");

                node = XMLFile.AppendNewNode("李老师", "Teachers", "男老师");
                node.SetAttribute("Name", "李刚");
                node.SetAttribute("Subject", "语文");
                node.SetAttribute("Age", "26");

                node = XMLFile.AppendNewNode("张老师ss","Teachers", "男老师");
                node.SetAttribute("Name", "张东");
                node.SetAttribute("Subject", "化学");
                node.SetAttribute("Age", "27");               
            }
            node = XMLFile.AppendNewNode("女老师", "Teachers");
            {
                node = XMLFile.AppendNewNode("张老师", "Teachers", "女老师");
                node.SetAttribute("Name", "张雪");
                node.SetAttribute("Subject", "化学");
                node.SetAttribute("Age", "27");

                node = XMLFile.AppendNewNode("蓝老师", "Teachers", "女老师");
                node.SetAttribute("Name", "蓝凌雪");
                node.SetAttribute("Subject", "化学");
                node.SetAttribute("Age", "27");
            }
            XMLFile.Close("Teachers.xml");
           
        }
        private static void CreatBooksXml()
        {
            XMLFile.Open("Books.xml", "Books");

            XmlElement node;

            node = XMLFile.AppendNewNode("Book", "Books");
            {
                node = XMLFile.AppendNewNode("Name", "Books", "Book");
                node.InnerText = "金瓶梅";
                node = XMLFile.AppendNewNode("Price", "Books", "Book");
                node.InnerText = "10";
                node = XMLFile.AppendNewNode("Count", "Books", "Book");
                node.InnerText = "10本";
            }
            node = XMLFile.AppendNewNode("Book", "Books");
            {
                node = XMLFile.AppendNewNode("Name", "Books", "Book");
                node.InnerText = "海";
                node = XMLFile.AppendNewNode("Price", "Books", "Book");
                node.InnerText = "110";
                node = XMLFile.AppendNewNode("Count", "Books", "Book");
                node.InnerText = "15本";
            }
            node = XMLFile.AppendNewNode("Book", "Books");
            {
                node = XMLFile.AppendNewNode("Name", "Books", "Book");
                node.InnerText = "水浒传";
                node = XMLFile.AppendNewNode("Price", "Books", "Book");
                node.InnerText = "110";
                node = XMLFile.AppendNewNode("Count", "Books", "Book");
                node.InnerText = "14本";
            }
            XMLFile.Close("Books.xml");
        }
    }
}
